<?php

namespace App\Notifications\Reservation;

use App\Models\Reservation\Reservation;
use App\Project\Sms\Ucpaas;
use App\Project\Sms\UcpaasSmsInterface;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;

class CancelReservationToPatient extends Notification implements UcpaasSmsInterface
{
    use Queueable;

    /**
     * @var \App\Models\Reservation\Reservation
     */
    protected $reservation;

    /**
     * @var \App\User
     */
    protected $doctor;

    public function __construct(Reservation $reservation)
    {
        $this->reservation = $reservation;
    }

    /**
     * Get the notification's delivery channels.
     * @param  mixed $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [Ucpaas::class];
    }

    public function template()
    {
        return 332983;
    }

    public function parameters($notifiable)
    {
        $time = Carbon::parse($this->reservation->time)->startOfDay();

        return implode(',', [
            $notifiable->name,
            $this->reservation->hospital->name . ' ' . $this->reservation->time . ' ' . $this->reservation->am ? '上午' : '下午',
            $time->hour($this->reservation->start)->format('H:i'),
            $time->hour($this->reservation->end)->format('H:i')
        ]);
    }

    public function result($result)
    {

    }
}
